//
//  JLPresentationController.swift
//  WBDemo
//
//  Created by Jin on 18/04/2018.
//  Copyright © 2018 com.baidu.123. All rights reserved.
//

import UIKit

class JLPresentationController: UIPresentationController {
    
    var presentedFrame = CGRect.zero
    
    override func containerViewWillLayoutSubviews() {
        super.containerViewWillLayoutSubviews()
        
        containerView?.insertSubview(cover, at: 0)
        cover.frame = (containerView?.bounds)!
        
        presentedView?.frame = presentedFrame
    }
    
    // MARK: - 懒加载
    private lazy var cover:UIView = {
        let otherView = UIView()
        otherView.backgroundColor = UIColor(white: 0.8, alpha: 0.6)
        let tap = UITapGestureRecognizer(target: self, action: #selector(coverClick))
        otherView.addGestureRecognizer(tap)
        return otherView
    }()
    
    // MARK: - 内部控制方法
    @objc private func coverClick(){
        JLog(message: "")
        presentedViewController.dismiss(animated: true, completion: nil)
    }
}
